﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TTS
{
    public class TTSManager
    {
        private static Dictionary<string, TextToSpeech> ttsDic = new Dictionary<string, TextToSpeech>();

        public static TextToSpeech getTextToSpeech(string index)
        {
            int tmp = 0;
            try
            {
                tmp = Convert.ToInt32(index);
            }
            catch (FormatException e)
            {
                Console.WriteLine("Input string is not a sequence of digits.");
            }
            catch (OverflowException e)
            {
                Console.WriteLine("The number cannot fit in an Int32.");
            }

            if (!ttsDic.ContainsKey(index))
                ttsDic.Add(index.ToString(), new TextToSpeech(tmp));
            return ttsDic[index];
        }

        public static string recognize(byte[] byteArray)
        {
            Recognition recognition = new Recognition();
            return recognition.detect(byteArray);
        }
    }
}